package au.com.evoCoach.dto;

import java.util.ArrayList;
import java.util.List;

import au.com.evoCoach.domain.Team;
import au.com.evoCoach.domain.TeamPlayer;
import au.com.evoCoach.enums.Position;

public class TeamDetails {
	private Team team;
	private List<TeamPlayer> players;
	private List<TeamPlayer> nonSelectedPlayers;

	public TeamDetails(Team team, List<TeamPlayer> players, List<TeamPlayer> nonSelectedPlayers) {
		this.team = team;
		this.players = players;
		this.nonSelectedPlayers = nonSelectedPlayers;
	}

	public Team getTeam() {
		return team;
	}

	public void setTeam(Team team) {
		this.team = team;
	}

	public List<TeamPlayer> getPlayers() {
		return players;
	}

	public void setPlayers(List<TeamPlayer> players) {
		this.players = players;
	}
	
	
	
	public List<TeamPlayer> getNonSelectedPlayers() {
		return nonSelectedPlayers;
	}

	public void setNonSelectedPlayers(List<TeamPlayer> nonSelectedPlayers) {
		this.nonSelectedPlayers = nonSelectedPlayers;
	}

	public List<TeamPlayer> getDefenders() {
		List<TeamPlayer> requiredPlayers = new ArrayList<TeamPlayer>();
		for (TeamPlayer player : players) {
			if (player.getPlayer().playsPosition(Position.DEF)) {
				requiredPlayers.add(player);
			}
		}
		
		return requiredPlayers;
	}
	
	public List<TeamPlayer> getMidfielders() {
		List<TeamPlayer> requiredPlayers = new ArrayList<TeamPlayer>();
		for (TeamPlayer player : players) {
			if (player.getPlayer().playsPosition(Position.MID)) {
				requiredPlayers.add(player);
			}
		}
		
		return requiredPlayers;
	}
	
	public List<TeamPlayer> getForwards() {
		List<TeamPlayer> requiredPlayers = new ArrayList<TeamPlayer>();
		for (TeamPlayer player : players) {
			if (player.getPlayer().playsPosition(Position.FWD)) {
				requiredPlayers.add(player);
			}
		}
		
		return requiredPlayers;
	}
	
	public List<TeamPlayer> getRucks() {
		List<TeamPlayer> requiredPlayers = new ArrayList<TeamPlayer>();
		for (TeamPlayer player : players) {
			if (player.getPlayer().playsPosition(Position.RUCK)) {
				requiredPlayers.add(player);
			}
		}
		
		return requiredPlayers;
	}	
	
}
